//
//  NLPhotoAssetUtil.m
//  nl_photo_picker
//
//  Created by 赵优路 on 2019/7/17.
//

#import "NLPhotoAssetUtil.h"
#import <MobileCoreServices/MobileCoreServices.h>

@implementation NLPhotoAssetUtil
+ (PHAsset *)getAssetFromImagePickerInfo:(NSDictionary *)info {
    if (@available(iOS 11, *)) {
        return [info objectForKey:UIImagePickerControllerPHAsset];
    }
    NSURL *referenceURL = [info objectForKey:UIImagePickerControllerReferenceURL];
    if(referenceURL == nil){
        return nil;
    }
    PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithALAssetURLs:@[ referenceURL ]
                                                                   options:nil];
    if (result == nil) {
        return nil;
    }
    return result.firstObject;
}
@end
